#include <iostream>
using namespace std;

int main()
{
	string a, b;
	int team = 1, star = 1;
	cin >> a >> b;
	for(int i = 0; i < a.length(); i++)
		team *= (int)a[i] - 64;
	for(int i = 0; i < b.length(); i++)
		star *= (int)b[i] - 64;
	team %= 47;
	star %= 47;
	if(team == star)
		cout << "GO" << endl;
	else
		cout << "STAY" << endl;
	return 0;
}
